package com.pounds.control;

import com.pounds.pojo.Health;
import com.pounds.service.HealthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("peaceful/health")
public class HealthControl {

    @Autowired
    private HealthService healthService;

    @GetMapping("select")
    public List<Health> getHealthList() {
        return healthService.getHealthList();
    }

    @GetMapping("new")
    public String addHealth(int user, String morning, String noon, String night, String sleep, String need, String note) {
        return healthService.addHealth(user, morning, noon, night, sleep, need, note);
    }

    @GetMapping("delete")
    public String deleteHealth(int id) {
        return healthService.deleteHealth(id);
    }

    @GetMapping("update")
    public String updateHealth(int id, int user, String morning, String noon, String night, String sleep, String need, String note) {
        return healthService.updateHealth(id, user, morning, noon, night, sleep, need, note);
    }
}
